Skip to content

Improve DateTools.format (padding and day of the year) - #12214

Open
MattTuttle wants to merge 2 commits into
HaxeFoundation:developmentfrom
MattTuttle:dateformat
Open

MattTuttle wants to merge 2 commits into
HaxeFoundation:developmentfrom
MattTuttle:dateformat

Conversation

@MattTuttle

Copy link
Copy Markdown

Padding for numbers is optional by adding dash (%-*).

DateTools.format(new Date(2025, 1, 2, 0, 0, 0), "%-d/%-m"); // removes leading zero from day and month

Support day of the year (%j).

DateTools.format(Date.now(), "%j"); // returns the day of the year

@MattTuttle
MattTuttle force-pushed the dateformat branch 2 times, most recently from dfaff37 to 1ad0f4a Compare April 26, 2025 21:34
* Padding for numbers is optional by adding dash (%-*).
* Support day of the year (%j).
@MattTuttle

MattTuttle commented Apr 26, 2025 •

Copy link
Copy Markdown
Author

Date.getTime() returns a different value on Lua, Python, and PHP apparently. I had to increment the day by one on those targets.

There's also some inconsistencies on Windows and Mac (Date.getFullYear) with PHP and Neko. I'm not sure how you want to handle those.

@skial skial mentioned this pull request Apr 28, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants